import 'package:flutter/material.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/controller/books.dart';
import 'package:ichinesereader/controller/cache.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/buttons/myFavoriteButtonBar.dart';
import 'package:ichinesereader/widgets/grids/bookGridWithCheckBox.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';

class MyFavoriteBooksForIndividual extends GetView<BooksController> {
  final GlobalKey progressPageKey = GlobalKey();
  final box = Hive.box('appconfig');

  @override
  Widget build(BuildContext context) {
    Log.debug('build IndividualMyFavorites');
    final box = Hive.box('appconfig');
    bool isIndividual = box.get(CacheManagerKey['nanhairole'].toString()) ==
        Constants.NanhaiRole_Individual;

    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Column(
        children: [
          Container(
            margin: EdgeInsets.symmetric(vertical: 6.0),
            height: 58,
            child: isIndividual ? FavoriteButtonBar() : Text(''),
          ),
          Expanded(
              child: Container(
            //margin: EdgeInsets.only(top: 12.0),
            child: controller.obx(
              (data) => BookGridWithCheckBox(
                books: controller.myFavoriteBookItems,
                readingType: NanhaiBookReadingTypes.favorite,
              ),
              onEmpty: Center(child: Text('No book has been added'.tr)),
              onLoading: Container(),
              // onLoading: Center(
              //     child: CircularProgressIndicator(
              //   backgroundColor: Get.theme.primaryColorDark,
              //   strokeWidth: 9.0,
              // )),
            ),
          )),
        ],
      ),
    );
  }
}
